import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.CharsetUtil;

public class PrintServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        try {
            if (msg instanceof ByteBuf) {
                System.out.println("PrintServerHandler channelRead：" + ((ByteBuf) msg).toString(CharsetUtil.US_ASCII));
            } else if (msg instanceof String) {
                System.out.println("PrintServerHandler channelRead：" + msg);
            }
            super.channelRead(ctx, msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
